package com.zhouxiao.multithreading.runningcallback;

/**
 * @author 周明阳
 * mail:gqzmy@outlook.com
 * 时间:2018-03-13 10:08
 */

public class Tortoise extends Animal {

    public Tortoise() {
        setName("乌龟");
    }

    @Override
    public void runing() {
        while (flag) {
            double dis = 0.5;
            length -= dis;
            System.out.println("===========乌龟跑了" + dis + "米，距离终点还有" + length + "米===========");
            if (length <= 0) {
                length = 0;
                System.out.println("乌龟胜利了！！！");
                if (calltoback != null) {
                    flag = false;
                    calltoback.win();
                }
            }

        }
    }
}
